package com.heima.dao;

import com.heima.domain.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface IOrdersDao {
    @Select("select * from orders")
    @Results(id="OrdersProductMap",
    value = {
            @Result(id=true,column = "id",property = "id"),
            @Result(column ="productId",property = "productId"),
            @Result(column = "productId",property = "product",javaType = com.heima.domain.Product.class,
                    one=@One(select="com.heima.dao.IProductDao.findOneById"))
             }
    )
    List<Orders> findAll();
    @Select("select * from orders where id=#{id}")
    @Results(id = "OrderPMTMap",
            value = {
                     @Result(id=true,column ="id",property = "id"),
                     @Result(column ="productId",property ="product",javaType = com.heima.domain.Product.class,
                             one=@One(select="com.heima.dao.IProductDao.findOneById")),
                    @Result(column = "memberId",property = "member",javaType = com.heima.domain.Member.class,
                             one = @One(select = "com.heima.dao.IMemberDao.findById")),
                    @Result(column = "id",property = "travellers",javaType =java.util.List.class,
                              many = @Many(select = "com.heima.dao.ITravellerDao.findById"))
            }
    )
    Orders findById(String id);
}
